/*
 * Copyright (C) 2022 KylinSoft Co., Ltd.
 *
 * This program is free software: you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation, either version 3 of the License, or (at your option) any later
 * version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program. If not, see <https://www.gnu.org/licenses/>.
 */

#ifndef WIREDLINKSTATE_H
#define WIREDLINKSTATE_H

#include <QObject>
#include <QDBusInterface>
#include <QDBusReply>
#include <QDebug>
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
#include <QtQml/qqml.h>
#endif
#include "wirelessstatus.h"

class WirelessStatus;
//提供给Qml有线网络状态信号的类
class WiredLinkState: public QObject
{
    Q_OBJECT
#if QT_VERSION >= QT_VERSION_CHECK(5,15,0)
    QML_ELEMENT
#endif
public:

    Q_PROPERTY(bool wiredState READ getWiredState NOTIFY wiredLinkChanged)
    Q_PROPERTY(int wiredStateValue READ getWiredStateValue NOTIFY wiredValueChanged)

    explicit WiredLinkState(QObject *parent = nullptr);

    //暴露给WirelessStatus使用的变量
    bool wiredStateChange;

    //获取有线网络连接状态
    bool getWiredState();

    //获取有线网络链接Connectivity的值
    int getWiredStateValue();

    //初始化网络状态信息
    bool initConnectionInfo();

signals:
    // 信号：可以直接在QML中访问信号
    void wiredLinkChanged(bool str);

    void wiredValueChanged(int stateValue);

private slots:
    //后台私有属性槽函数
    void onPropertiesChanged(QVariantMap);

private:
    bool myWiredState;

    int myWiredStateValue;

};

#endif // WIREDLINKSTATE_H
